﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Admin_Gallery.ascx.cs" Inherits="Administrator_Controls_Admin_Gallery" %>
<script src="../resources/scripts/jquery-1.6.4.js" type="text/javascript"></script>
<script src="../resources/scripts/jquery.tablednd_0_5.js" type="text/javascript"></script>
<script type="text/javascript">
    var variable = "0";
    var j = jQuery.noConflict();
    j(document).ready(function () {
        j('#table-3').tableDnD({
            onDrop: function (table, row) {
                variable = j.tableDnD.serialize();
            }
        });
        j("input.order").click(function () {
            j.ajax({
                type: "POST",
                url: "/services/Admin.asmx/WLOrder",
                data: "{'id':'" + variable + "','module':'<%=ddlModule.SelectedValue %>'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                beforeSend: function () {
                    j("#<%=divMessage.ClientID %>").html("");
                },
                success: function (message) {
                    if (message.d == false) {
                        j("#<%=divMessage.ClientID %>").html("<div id='message-error' class='message message-error'><div class='image'><img src='../resources/images/icons/error.png' alt='Error' height='32' /></div><div class='text'><h6>L?i</h6><span>Chua th?c hi?n du?c!</span></div><div class='dismiss'><a href='#message-error'></a></div></div>");
                    }
                    else {
                        j("#<%=divMessage.ClientID %>").html("<div id='message-success' class='message message-success'><div class='image'><img src='../resources/images/icons/success.png' alt='Success' height='32' /></div><div class='text'><h6>Thông Báo</h6><span>C?p nh?t thành công !</span></div><div class='dismiss'><a href='#message-success'></a></div></div>");
                    }
                },
                error: function (errormessage) {
                    j("#<%=divMessage.ClientID %>").html("<div id='message-error' class='message message-error'><div class='image'><img src='../resources/images/icons/error.png' alt='Error' height='32' /></div><div class='text'><h6>L?i</h6><span>Chua th?c hi?n du?c!</span></div><div class='dismiss'><a href='#message-error'></a></div></div>");
                }
            });
        });
    });
</script>
<asp:HiddenField ID="hdfCheck" runat="server" />
<div class="box">
    <!-- box / title -->
    <div class="title">
        <h5 id="txtTitle" runat="server">
            Quản lí thư viện ảnh</h5>
    </div>
    <div id="divMessage" runat="server">
    </div>
    <div class="first-action">
        <div class="button">
            <a href="default.aspx?control=Admin_Gallery_AddNew">
                <input type="button" value="Thêm mới" /></a>
            <input type="button" class="order" value="Cập Nhật thứ tự" />
        </div>
        <div class="select">
            <asp:DropDownList runat="server" ID="ddlModule" AutoPostBack="true" OnSelectedIndexChanged="ddlModule_SelectedIndexChanged">
            </asp:DropDownList>
        </div>
    </div>
    <!-- end box / title -->
    <div class="table">
        <table id="table-3">
            <thead>
                <tr>
                    <th>
                        Số thứ tự
                    </th>
                    <th>
                        Hình Ảnh
                    </th>
                    <th>
                        Nội Dung
                    </th>
                    <th>
                        Ngày Tạo
                    </th>
                    <th class="edit">
                        Sửa
                    </th>
                    <th class="selected last">
                        <input type="checkbox" class="checkall" />
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater ID="rptData" runat="server">
                    <ItemTemplate>
                         <tr>
                            <td>
                                <%# (base.Cur_page( pagerContainer ) -1)* base.Page_size + Container.ItemIndex+1%>
                            </td>
                            <td>
                                <asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("THUMB_IMG")%>' AlternateText='<%#Eval("THUMB_IMG") %>' Width="70px" Height="70px"/>
                            </td>
                            <td>
                                <%#Eval("FULL_ARTICLE_DESCRIPTION")%>
                            </td>
                            <td>
                                <%#Eval("CREATED_DATE")%>
                            </td>
                            <td align="center">
                                <a href="default.aspx?control=Admin_Gallery_Edit&id=<%#Eval("ARTICLE_ID").ToString() + "&module_id=" + ddlModule.SelectedValue %>" class="edit"
                                    title="Chỉnh Sửa">Sửa</a>
                            </td>
                            <td align="center" class="last">
                                <input type="checkbox" class="item" runat="server" id="chkBox" value=<%#Eval("ARTICLE_ID").ToString() %> />
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
        <div class="pagination pagination-left last">
            <div class="pagerContainer" id="pagerContainer" runat="server">
            </div>
        <div class="action">
            <asp:DropDownList ID="ddlAction" runat="server" OnSelectedIndexChanged="ddlAction_SelectedIndexChanged"
                AutoPostBack="true" CssClass="selectwidth">
                <asp:ListItem Value="0" class="folder-open" Text="---Chọn hành động---"></asp:ListItem>
                <asp:ListItem Value="1" class="locked" Text="Di chuyển tới thùng rác"></asp:ListItem>
                <asp:ListItem Value="2" class="unlocked" Text="Xóa vĩnh viễn"></asp:ListItem>
            </asp:DropDownList>
            <div class="button">
                <a href="default.aspx?control=Admin_Gallery_AddNew">
                    <input type="button" value="Thêm mới" /></a>
                <input type="button" class="order" value="Cập nhật thứ tự" />
            </div>
        </div>
    </div>
</div>
